package com.cn.customer.housekeeping.housekeepingb.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.customer.housekeeping.housekeepingb.R;
import com.cn.customer.housekeeping.housekeepingb.bean.ProdctBean;
import com.cn.customer.housekeeping.housekeepingb.ui.base.BaseImgView;

import java.util.List;


/**
 * GridView加载数据的适配器
 *
 * @author Administrator
 */
public class MyGridViewReleaseAdpter extends BaseAdapter {

    private Context context;
    private List<ProdctBean> lists;//数据源


    public MyGridViewReleaseAdpter(Context context, List<ProdctBean> lists
                               ) {
        this.context = context;
        this.lists = lists;

    }


    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return lists.size() ;
    }

    @Override
    public ProdctBean getItem(int arg0) {
        // TODO Auto-generated method stub
        return lists.get(arg0 );
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_head_releasegridview, null);
            holder.tv_name = (TextView) convertView.findViewById(R.id.item_name);
            holder.iv_nul = (ImageView) convertView.findViewById(R.id.item_image);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_name.setText(lists.get(position).getName() + "");

        BaseImgView.ImageLoaderLoadimg(holder.iv_nul,
                lists.get(position).getUrl(), R.mipmap.icon_yuan, R.mipmap.icon_yuan, R.mipmap.icon_yuan, 60, 60, 20);


        return convertView;
    }

    static class ViewHolder {
        private TextView tv_name;
        private ImageView iv_nul;
    }
}